<template>
    <div id="MerchantDialog">
        <el-dialog title="添加空间" width="900px" :visible.sync="show">
            <vj-form @submit="onSubmit" @close="show=false" hide-reset :style-config="{labelWidth:'160px'}" :slot-idx="cfgList.length"
                     :loading="loading" class="vj-form" :cfg-list="cfgList"
                     :form-data.sync="formData"/>
        </el-dialog>
    </div>
</template>
<script lang="ts">
    import Vue, {ComponentOptions, VueConstructor} from "vue"
    import Component from 'vue-class-component'
    import {Mixins} from "vue-property-decorator";
    import {FormMixin} from "@/plugins/mixins/form";
    import {ActivityFormTB} from "@/config/table";
    import {ACTIVITY_FM, ACTIVITY_LINK_FM, CAPITAL_FM, MERCHANT_FM, TALENT_FM} from "@/config/form";
    import {cloneDeep, formatOptions, hookSubmit, updateCfgOption} from "vijay-util";
    import {requestByGet, requestByPost, requestByPut} from "@/utils/request";

    @Component
    export default class MerchantDialog extends Mixins(FormMixin) implements ComponentOptions<Vue> {
        name = "MerchantDialog"
        show = false;
        editId = null;
        formData = {};
        cfgList = MERCHANT_FM
        @hookSubmit()
        async onSubmit() {
            const requestFn = this.editId?requestByPut:requestByPost;
            await requestFn(`qqc/qqcSpaceentry/${this.editId ? 'edit' : 'add'}`, {...this.formData, id: this.editId});
            this.$message.success("操作成功！");
            this.show = false;
            this.$emit('refresh')
        }

        open(data={} as any) {
            this.show = true;
            this.formData = cloneDeep(data);
            this.editId = data.id;

        }
    }
</script>

<style scoped lang="scss">
    @import "~assets/common.scss";
    #MerchantDialog {
    }
</style>
